package com.example.bailin.giftsay.sort.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.bailin.giftsay.R;
import com.example.bailin.giftsay.entity.SingleEntity;
import com.example.bailin.giftsay.tool.MyApp;

import java.util.List;

/**
 * Created by bailin on 16/8/19.
 *
 * 单品ListView联动 左侧的ListView
 * 不用优化
 */
public class SingleLeftAdapter extends BaseAdapter {
    private SingleEntity entity;

    public void setEntity(SingleEntity entity) {
        this.entity = entity;
    }

    @Override
    public int getCount() {
        return entity.getData().getCategories() == null ? 0 : entity.getData().getCategories().size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = LayoutInflater.from(MyApp.getContext()).inflate(R.layout.item_listview_left, parent, false);
        TextView tvLeft = (TextView) convertView.findViewById(R.id.tv_left1);

        tvLeft.setTag(position);
        tvLeft.setText(entity.getData().getCategories().get(position).getName());
        return convertView;
    }
}